<template>
	<view class="wrap">
		<!-- <u-swiper :height="165" :list="imgList" :title="false" @click="imgListClick"></u-swiper> -->
		<image style="width: 100%; height: 330rpx" src="../../../static/img02.jpg" mode="aspectFill"></image>
		<view class="toolbar u-m-b-20">
			<u-grid class="grid" :col="3" :border="false">
				<u-grid-item :index="0" @click="navTo('/pages/bpm/myTaskTodo/myTaskTodo?MsgType=')">
					<u-badge style="z-index: 1" max="99" :absolute="true" :offset="[0, 40]"
						:value="taskTodoMsgNum"></u-badge>
					<u-icon class="grid-icon" name="chat" :size="45" color="#ea9a44"></u-icon>
					<view class="grid-text">待处理任务</view>
				</u-grid-item>
				<u-grid-item :index="0" @click="navTo('/pages/bpm/myTaskTodo/myTaskTodo?MsgType=' + 'check')">
					<u-badge style="z-index: 1" max="99" :absolute="true" :offset="[0, 40]"
						:value="taskCheckMsgNum"></u-badge>
					<u-icon class="grid-icon" name="clock" :size="45" color="#ea9a44"></u-icon>
					<view class="grid-text">待验收任务</view>
				</u-grid-item>
				<u-grid-item :index="1" @click="navTo('/pages/bpm/myTaskHistory/myTaskHistory')">
					<u-icon class="grid-icon" name="checkmark-circle" :size="45" color="#47cb66"></u-icon>
					<view class="grid-text">已办任务</view>
				</u-grid-item>
				<!-- <u-grid-item :index="2" @click="$tool.msg('开发中...')">
					<u-icon class="grid-icon" name="order" :size="45" color="#5a98ea" ></u-icon>
					<view class="grid-text">我相关的</view>
				</u-grid-item> -->
			</u-grid>
		</view>
		<u-collapse class="box u-p-b-5" :accordion="false" :value="['a-1']">
			<view class="item" v-for="(menu, index) in menuList" :key="menu.menuCode">
				<u-collapse-item :open="true" :name="menu.menuCode">
					<view class="title" slot="title">
						<u-icon :label="menu.menuName" size="20" :name="menu.menuIcon"></u-icon>
					</view>
					<u-grid class="grid u-m-t-20" :col="3" :border="false">
						<u-grid-item v-for="(child, index2) in menu.childList" :key="child.menuCode" v-if=""
							@click="navTo(child.url)">
							<u-icon class="grid-icon" :name="child.menuIcon != '' ? child.menuIcon : 'order'" :size="45"
								:color="child.menuColor != '' ? child.menuColor : '#666' "></u-icon>
							<view class="grid-text"
								:style="{ color: child.menuColor != '' ? '#666' : '#666' }">
								{{ child.menuName }}
							</view>
						</u-grid-item>
					</u-grid>
				</u-collapse-item>
			</view>
		</u-collapse>
	</view>
</template>
<script>
	import {
		menuList
	} from './menuList.js';
	export default {
		data() {
			return {
				taskTodoMsgNum: 0,
				taskCheckMsgNum: 0,

				tabBarValue: 0,
				imgList: [{
					image: '/static/img02.jpg'
				}],

				todoCount: 0,
				menuList: menuList
			};
		},
		onInit() {
			console.log('home.vue onInit');
		},
		onLoad() {
			console.log('home.vue onLoad');
			this.refreshCount();
		},
		onShow() {
			console.log('home.vue onShow');
			this.refreshCount();
		},
		onReady() {
			console.log('home.vue onReady');
		},
		methods: {
			tabBarClick(e) {
				/* if (e == 'user') {
					uni.navigateTo({
						url: '/pages/sys/basedoc/basedoc'
					})
				}
				if (e == 'home') {
				} */
			},
			navTo(url) {
				if (url.search('hse') == -1) {
					// return this.$u.toast('开发中...');
				}
				uni.navigateTo({
					url: url
				});
			},
			refreshCount() {
				let msgType = '';
				this.$api
					.queryTaskTodoMsgNum(msgType)
					.then((resp) => {
						let {
							data
						} = resp;
						let jsonData = JSON.parse(data);
						let {
							taskCheckMsgNum,
							taskTodoMsgNum
						} = jsonData;
						this.taskCheckMsgNum = taskCheckMsgNum
						this.taskTodoMsgNum = taskTodoMsgNum
					})
					.catch((error) => {});
			},
			imgListClick(index) {},
			itemClick(index) {}
		}
	};
</script>
<style lang="scss">
	@import './index.scss';

	page {
		background-color: #f8f8f8;
	}
</style>